/**
 * 
 */
package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import properties.DefaultProperties;

/**
 * This class provides the menu for the main window.
 * @author Kevin Wagner
 * @version 1.0
 */
public class MainMenu extends JMenuBar implements ActionListener {

	private static final long serialVersionUID = -4905765460781590696L;
	private DefaultProperties props;
	private JMenu fileMenu,settingMenu,infoMenu;
	private JMenuItem exitItem,aboutItem,settingMenuItem;
	
	/**
	 * @param props properties
	 * 
	 */
	public MainMenu(DefaultProperties props){
		this.props=props;
		fileMenu=new JMenu(props.getLocalizedText("file"));
		this.add(fileMenu);
		exitItem=new JMenuItem(props.getLocalizedText("exit"));
		exitItem.addActionListener(this);
		fileMenu.add(exitItem);
		
		settingMenu=new JMenu(props.getLocalizedText("settings"));
		this.add(settingMenu);
		settingMenuItem=new JMenuItem(props.getLocalizedText("settings"));
		settingMenuItem.addActionListener(this);
		settingMenu.add(settingMenuItem);
		
		infoMenu=new JMenu(props.getLocalizedText("info"));
		aboutItem=new JMenuItem(props.getLocalizedText("about"));
		aboutItem.addActionListener(this);
		infoMenu.add(aboutItem);
		this.add(infoMenu);
	}

	@Override
	public void actionPerformed(ActionEvent ev) {
		if(ev.getSource().equals(exitItem)){
			System.exit(0);
		}else if(ev.getSource().equals(aboutItem)){
			new InfoWindow(props);
		}else if(ev.getSource().equals(settingMenuItem)){
			new SettingWindow(props);
		}
		
	}

}
